home *** CD-ROM | disk | FTP | other *** search
-
- Experiments with Bitmaps, hDCs, Images, Pictures, and AutoRedraw
- ----------------------------------------------------------------
-
- I gave up trying to write a dozen different sample programs to figure
- out what's going on with VB, AutoRedraw, hDC and the Windows GDI. So, I
- wrote a program (actually drew a form, the code was no big deal) which
- exercises pretty much all of the graphics methods in terms of refreshing,
- cls, pset/line, etc., along with the GDI stuff like BitBlt, and the GDI
- line drawing (MoveTo, LineTo, SetPixel, etc.). There are 2 picture box
- controls (labelled P1 [left] and P2 [right]) which you can transfer from
- one to the other using either VB's transfer (e.g., P2.Picture = P1.Image),
- copy to the clipboard, etc. P1 is the source for most operations, and you
- can draw on it by clicking and hold the left mouse button and then moving
- around to draw freehand. You'll be drawing with the VB statements to
- start with, but if you click the VB Draw Mode command button, it'll toggle
- you to GDI drawing, and if you click again you'll be back in VB mode. A
- quick note about GDI drawing, if AutoRedraw is on (see the checkbox), the
- you won't see what you're drawing until you do a Refresh or if you have
- the GDI Draw Auto-Refresh checked which will do a .Refresh method
- everytime a GDI statement is executed (LineTo, BitBlt, etc.).
-
- The BitBlt-->Image button will BitBlt the picture's "screen" to the
- .Image. Confused? Take a look at the code, play with it and it'll become
- less confusing (no claims on making it clear!).
-
- P2 is the destination for the BitBlt, and VB's transfer methods. Note the
- option buttons settings which determine whether the .Picture or .Image
- property will be used for ClipBoard functions and VB transfer. Note that
- in some cases if .Image is selected, it won't be used as a destination
- since it's a read-only property. In those cases, the program will only
- use the .Picture property. However, there's always a status message
- displayed so you'll know what you're getting. Also note that there is a
- list box where you can choose which BitBlt mode to use. In a future
- version I'll allow Raster Operations (ROPs) other than the normal ones to
- be entered. There are some pretty interesting combinations.
-
- Hide Picture and Disable Picture affect the .Visible and .Enabled
- properties, respectively. The buttons will change to let you know what
- action will be taken when they're clicked. Image-->Picture will copy that
- picture's .Image Property to the .Picture property, i.e., .Picture=.Image.
-
- The RGB colored boxes below each picture will bring up a dialog box
- allowing you to set the Foreground and Background colors. Note that if
- the color is initally set to an indexed system color (e.g., &H80000005 or
- COLOR_WINDOW), the routine will convert it to an RGB color (e.g.,
- &H00FFFFFF). I would've converted the color back to a system color (if
- possible), but it doesn't necessarily make sense to do so and I don't know
- of a function that'd do it anyway (besides to go through each system color
- looking for a match).
-
- The PopOver button will pop up a large dialog box which should cover the
- picture boxes which gives you another way to see AutoRedraw in action.
- Click on "I've Had It!" when you've had enough and need to get some sleep.
-
- I think that pretty much covers the basics, the rest is left as an
- exercise for the user (that's you), since that's what this thing is for!
- Let me know if you have any questions or problems. I coded it on an
- 800x600 screen, but I'm pretty sure I sized it properly for a 640x480
- screen. If not, let me know and I'll load up my 640x480 driver and fix
- it. Have fun with it!
-
- - Ted Young
- [76703,4343]
-
- p.s. While the the LoadPicture() function gives you the ability
- to load a bitmap/metafile into the picture boxes, the SavePicture() is
- currently not implemented (I got tired of playing with it).
-
- I'm planning on doing some stuff with the GDI region and clipping
- functions sometime soon. If you have any comments or suggestions, please
- let me know!
-